package com.javatest;

public class RunTest extends Thread {

    private int time; //爬行100需要的时间
    private int num;//爬行多少个100米

    public RunTest(String name, int time, int kilometer) {
        super(name);
        this.time = time;
        this.num = kilometer * 1000 / 100;
    }

    @Override
    public void run() {
        while (num>0){
            try {
                Thread.sleep(time);
            }catch (Exception e){
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"爬行了100米");
            num--;
        }
        System.out.println(Thread.currentThread().getName()+"爬到终点了");
    }
}
